package cn.task.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.task.po.Task;
import cn.task.po.Taskapplication;
import cn.task.po.TaskapplicationVo;
import cn.task.service.TaskService;
import cn.task.service.TaskapplicationService;
import cn.userManager.po.User;
import cn.userManager.service.UserService;
@Controller
public class TaskapplicatController {
	@Autowired
	private TaskapplicationService taskapplicationService;
	@Autowired
	private TaskService taskService;
	@Autowired
	private UserService userService;
	@RequestMapping(value="/getTaskAppInform")
	public @ResponseBody List<User> getTaskAppInform(HttpServletRequest request) throws Exception
	{
		ArrayList<User> userList=new ArrayList<User>();
		String taskId=request.getParameter("taskid");
		List<Taskapplication> list=taskapplicationService.selectTaskapplicat(taskId);
		for(Taskapplication taskapp:list)
		{
			String username=taskapp.getReceiverid();
			User user=userService.selectByName(username);
			userList.add(user);
		}
		return userList;
	}
	@RequestMapping(value="/getTaskAppInAccount")
	public @ResponseBody int getTaskAppInAccount(HttpServletRequest request) throws Exception
	{
		String taskId=request.getParameter("taskid");
		return taskapplicationService.countTaskapplication(taskId);
	}
	@RequestMapping(value="/shareTask.action")
	public @ResponseBody int shareTask(HttpServletRequest request)
	{
		String taskId=request.getParameter("taskid");
		return 0;
	}
}
